#ifndef __TEXTURE_H__
#define __TEXTURE_H__

#include "../../Header/Header.h"
#include "../Shader.h"
#include "Resource.h"
#include "ResourceBank.h"

class TextureEx : public Resource
{
protected:
	GLuint* m_TBO;
	GLuint m_iTextures;
	char** m_strFiles;
	GLenum m_TextureTarget;
protected:
	//Binding texture data into vRam
	virtual void Load();
	void LoadTexture2D();
	void LoadTextureCube();
	virtual ~TextureEx();
	friend class ResourceBank;
	friend class ResourceManagement;
public:
	TextureEx() :Resource(), m_TBO(0), m_iTextures(0){}
	virtual void Init2D(char* strFileTexture);
	virtual void Init2D(char** strFileTextures, int iCount);
	virtual void InitCube(char** strFileTextures, int iCount = 5);

	//Binding to data buffer
	virtual void Render(const Shader* sha);

	//release
	virtual void Unrender();

	//Increase user count when it has reference
	virtual TextureEx* Reference();

	//Decrease user count when it has dereference
	//if user count down to 0,
	//this method will delete buffer data
	//and set loadins flag = false
	//if isKilledAfterUnUse = false all data will release.
	virtual void Dereference();
};

#endif